package com.shhic.itsed.mws.deviceintf;

import lombok.ToString;

import java.io.Serializable;

/**
 * 原始标签区标识
 * @author 张文硕
 *
 */
@ToString
public class RawTagField implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private RawTagBank bank;	//区域
	private int offset;		//偏移
	private int length;		//长度
	private SizeUnit sizeUnit = SizeUnit.WORD;	//长度单位，默认是字（WORD）
	private TagOperate tagOperate = TagOperate.READ;	//标签操作类型，默认是读
	private String fieldValue;	//标签区值，以16进制符号表示，不带首部的0x；如果本对象用于下达读命令，则此域为空；如果用于上传标签读取结果，则这里有值。如果某个域读取失败，则此处也为null。
	
	public RawTagField() {
	}
	
	
	
	public RawTagField(RawTagBank bank, int offset, int length) {
		this.bank = bank;
		this.offset = offset;
		this.length = length;
	}



	public RawTagBank getBank() {
		return bank;
	}
	public void setBank(RawTagBank bank) {
		this.bank = bank;
	}
	public int getOffset() {
		return offset;
	}
	public void setOffset(int offset) {
		this.offset = offset;
	}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	public SizeUnit getSizeUnit() {
		return sizeUnit;
	}
	public void setSizeUnit(SizeUnit sizeUnit) {
		this.sizeUnit = sizeUnit;
	}
	public String getFieldValue() {
		return fieldValue;
	}

	public void setFieldValue(String fieldValue) {
		this.fieldValue = fieldValue;
	}

	public TagOperate getTagOperate() {
		return tagOperate;
	}

	public void setTagOperate(TagOperate tagOperate) {
		this.tagOperate = tagOperate;
	}

	@Override
	public String toString() {
		return bank.name()+"."+length+"."+offset + " ="+fieldValue;
	}
	
	//原始描述，格式是bank.length.offset，各个域都是数字
	public String toFieldOriDesc() {
		return String.format("%d.%d.%d", bank.ordinal(),length,offset );
	}
	
}
